Validate DSA parameters when verifying DSA key.#10381
Validate DSA parameters when verifying DSA key.#10381kareem-wolfssl wants to merge 4 commits intowolfSSL:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds DSA public key/domain parameter validation to prevent signature verification with malformed parameters (e.g., g = 1, y = 1) and exposes the validation as a public API, with a new regression test.
Changes:
- Add new public API
wc_DsaCheckPubKey()for validating DSA domain parameters + public key. - Call
wc_DsaCheckPubKey()fromwc_DsaVerify_ex()prior to signature math. - Add an API test that constructs malformed keys (requires
WOLFSSL_PUBLIC_MP) and asserts verify/validation rejection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| wolfssl/wolfcrypt/dsa.h | Exposes wc_DsaCheckPubKey() as a public API. |
| wolfcrypt/src/dsa.c | Implements key/parameter checks and enforces them in DSA verify. |
| tests/api/test_dsa.h | Registers the new API test. |
| tests/api/test_dsa.c | Adds regression coverage for malformed DSA params/pubkeys and verify rejection. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
Retest this please |
|
Retest this please |
Thanks to Kr0emer for the report.
| * return 0 on success, BAD_FUNC_ARG when the key fails validation, or a | ||
| * negative error code on internal failure. | ||
| */ | ||
| int wc_DsaCheckPubKey(DsaKey* key) |
There was a problem hiding this comment.
Consider a new macro for customers who don't want this... Code size / performance impact. Something like NO_DSA_PUBKEY_CHECK. On by default. Don't forget to add to .wolfssl_known_macro_extras . Its okay if you want to push back on this since very few people are/should be using DSA at this point.
…ed DSA public key check.
Description
Fixes zd#21694
Testing
PoC, newly added test
Checklist